
import java.util.ArrayList;


/**
 * Represents a music CD
 * 
 * A music CD is lend and reserve able
 * 
 * Special information: Interprets, Genre
 */
public class MusicCD extends LendReserveItem {
    private MusicGenre _genre;
    private ArrayList<Interpret> _interprets;
    
    /**
     * Constructor 
     * 
     * @param title Title of the new music cd
     * @param interpret Main interpret
     * @param genre Music genre
     * @param description 
     */
    public MusicCD(String title, Interpret interpret, MusicGenre genre, String description) {
        super(title, description);
        _genre = genre;
        _interprets = new ArrayList<Interpret>();
        _interprets.add(interpret);
    }
    
    /**
     * Specific getter's
     */
    public MusicGenre getGenre() {
        return _genre;
    }
    public Interpret[] getInterprets() {
        Interpret[] interpets = new Interpret[_interprets.size()];
        return _interprets.toArray(interpets);
    }
    
    @Override
    public String toString() {
        StringBuilder rv = new StringBuilder();
        rv.append("Music-CD ");
        rv.append(super.toString());
        for (Interpret i : _interprets) {
            rv.append(", ");
            rv.append(i.getName());
        }
        rv.append(", ");
        rv.append(_genre);
        return rv.toString();
    }
    
    /**
     * Adds an additional interpret
     * @param i interpret
     */
    public void addInterpret(Interpret i) {
        _interprets.add(i);
    }
}
